package com.ruoyi.web.controller.laiqianba.source;

import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.db.domain.SourceDataCallbackLog;
import com.ruoyi.source.service.ISourceDataCallbackLogService;
import com.ruoyi.web.wrapper.SourceDataCallbackLogWrapper;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 线索回调日志Controller
 * 
 * @author ruoyi
 * @date 2023-12-28
 */
@RestController
@RequestMapping("/source/callbackLog")
public class SourceDataCallbackLogController extends BaseController
{
    @Autowired
    private ISourceDataCallbackLogService sourceDataCallbackLogService;

    /**
     * 查询线索回调日志列表
     */
    @PreAuthorize("@ss.hasPermi('source:callbackLog:list')")
    @GetMapping("/list")
    public TableDataInfo list(SourceDataCallbackLog sourceDataCallbackLog)
    {
        startPage();
        List<Map<String, Object>> list = sourceDataCallbackLogService.selectSourceDataCallbackLogMapList(sourceDataCallbackLog);
        list = new SourceDataCallbackLogWrapper(list).wrap();
        return getDataTable(list);
    }

    /**
     * 导出线索回调日志列表
     */
    @PreAuthorize("@ss.hasPermi('source:callbackLog:export')")
    @Log(title = "线索回调日志", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SourceDataCallbackLog sourceDataCallbackLog)
    {
        List<SourceDataCallbackLog> list = sourceDataCallbackLogService.selectSourceDataCallbackLogList(sourceDataCallbackLog);
        ExcelUtil<SourceDataCallbackLog> util = new ExcelUtil<SourceDataCallbackLog>(SourceDataCallbackLog.class);
        util.exportExcel(response, list, "线索回调日志数据");
    }

    /**
     * 获取线索回调日志详细信息
     */
    @PreAuthorize("@ss.hasPermi('source:callbackLog:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(sourceDataCallbackLogService.selectSourceDataCallbackLogById(id));
    }

    /**
     * 新增线索回调日志
     */
    @PreAuthorize("@ss.hasPermi('source:callbackLog:add')")
    @Log(title = "线索回调日志", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SourceDataCallbackLog sourceDataCallbackLog)
    {
        return toAjax(sourceDataCallbackLogService.insertSourceDataCallbackLog(sourceDataCallbackLog));
    }

    /**
     * 修改线索回调日志
     */
    @PreAuthorize("@ss.hasPermi('source:callbackLog:edit')")
    @Log(title = "线索回调日志", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SourceDataCallbackLog sourceDataCallbackLog)
    {
        return toAjax(sourceDataCallbackLogService.updateSourceDataCallbackLog(sourceDataCallbackLog));
    }

    /**
     * 删除线索回调日志
     */
    @PreAuthorize("@ss.hasPermi('source:callbackLog:remove')")
    @Log(title = "线索回调日志", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(sourceDataCallbackLogService.deleteSourceDataCallbackLogByIds(ids));
    }
}
